//
//  JLCMineWithdrawRecordController.m
//  Srb_ios
//
//  Created by Ji on 2018/9/18.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "ZfZunNJLCFMineWithdrawRecordControllerfUTkiJ.h"
#import "sHkPtEJLCFMineRequestozAYZs.h"
#import "hphaptJLCFMineMoneyLogResultModeldhpqVh.h"
#import "QWYDliJLCFMineWithdrawCellWMSlXe.h"

@interface JLCMineWithdrawRecordController ()
{
    NSInteger _pageNumber;
}

@property (nonatomic, strong) NSMutableArray *DSAEKhmoneyArrJHumFd;

@end

@implementation JLCMineWithdrawRecordController

- (NSMutableArray *)DSAEKhmoneyArrJHumFd
{
    if (!_DSAEKhmoneyArrJHumFd) {
        _DSAEKhmoneyArrJHumFd = [NSMutableArray array];
    }
    return _DSAEKhmoneyArrJHumFd;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addNavigationBar];
    self.navigationBar.title = @"提现记录";
    self.tableView.backgroundColor = QTZ_Gray237;
    [self loadData];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadData
{
    [self.DSAEKhmoneyArrJHumFd removeAllObjects];
    _pageNumber = 1;
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setSafeObject:@(_pageNumber) forKey:@"page"];
    [params setSafeObject:@"withdraw" forKey:@"type"];
    
    [sHkPtEJLCFMineRequestozAYZs moneyLogWithParams:params loadingInView:self.view success:^(hphaptJLCFMineMoneyLogResultModeldhpqVh *money) {
        [self hideNoMoreDataNotice];
        if (money.data.count > 0) {
            [self.DSAEKhmoneyArrJHumFd addObjectsFromArray:money.data];
        } else {
            self.tableView.tableHeaderView = nil;
            [self showNoMoreDataNotice:@"没有更多了"];
        }
        [self.tableView reloadData];
        [self endRefresh];
    } failure:^(NSString *error) {
        [self showNotice:error];
        [self endRefresh];
    }];
    
    
}

- (void)loadMoreData
{
    
    _pageNumber ++;
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setSafeObject:@(_pageNumber) forKey:@"page"];
    [params setSafeObject:@"withdraw" forKey:@"type"];
    
    [sHkPtEJLCFMineRequestozAYZs moneyLogWithParams:params loadingInView:self.view success:^(hphaptJLCFMineMoneyLogResultModeldhpqVh *money) {
        if (money.data.count > 0) {
            
            [self.DSAEKhmoneyArrJHumFd addObjectsFromArray:money.data];
        } else {
            [self showNoMoreDataNotice:@"没有更多了"];
        }
        [self.tableView reloadData];
        [self endLoadMore];
    } failure:^(NSString *error) {
        [self showNotice:error];
        [self endLoadMore];
    }];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.DSAEKhmoneyArrJHumFd.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 128;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    QWYDliJLCFMineWithdrawCellWMSlXe *cell = [QWYDliJLCFMineWithdrawCellWMSlXe dequeueReusableCellForTableView:tableView];
    cell.data = [self.DSAEKhmoneyArrJHumFd safeObjectAtIndex:indexPath.section];
    [cell reloadData];
    return cell;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *rRHNlxheaderViewfJQeRl = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, 10)];
    rRHNlxheaderViewfJQeRl.backgroundColor = [UIColor clearColor];
    return rRHNlxheaderViewfJQeRl;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

@end
